﻿using System;
using System.Collections.Generic;
using VideoSeller.Business.Data.Entities;
using System.Linq;
using VideoSeller.Business.Data;
//using VideoSeller.Business.Data.Entities;
using VideoSeller.Business.Models;
using VideoSeller.Core.Interfaces;
using VideoSeller.Core.Configuration;

namespace VideoSeller.Web.Models
{
	public class VSMChartPeriodViewModel : BaseViewModel
	{
		public IEnumerable<StatisticOnlineItem> Items { get; set; }

		public string StartDate { get; set; }

		public string StartTime { get; set; }

		public string EndDate { get; set; }

		public string EndTime { get; set; }

		public DateTime StartDateTime
		{
			get
			{
				if (!string.IsNullOrEmpty(StartDate) && !string.IsNullOrEmpty(StartTime))
				{
					return DateTime.Parse(string.Format("{0} {1}", StartDate, StartTime));
				}

				if (!string.IsNullOrEmpty(StartDate))
				{
					return DateTime.Parse(StartDate);
				}

				return DateTime.MinValue;
			}
		}

		public DateTime EndDateTime
		{
			get
			{
				if (!string.IsNullOrEmpty(EndDate) && !string.IsNullOrEmpty(EndTime))
				{
					return DateTime.Parse(string.Format("{0} {1}", EndDate, EndTime));
				}

				if (!string.IsNullOrEmpty(EndDate))
				{
					return DateTime.Parse(EndDate);
				}

				return DateTime.MinValue;
			}
		}
        public IQueryable chartVSMPeriod
        {
            get
            {
                var postingModel = IoC.Resolve<PostingModel>();
                return postingModel.getVSMByPeriod(StartDateTime, EndDateTime);
              }
        }
	}
}